# -*- coding: utf-8 -*-

'''
@project : SmartHomeVideo
@FileName: video_load
@Author  :linych 
@Time    :2021/2/25 18:22
@Desc  : 
'''



# import ffmpeg
#
# #
# # def dowmload(vpath):
# #
# #     probe = ffmpeg.probe(vpath)
# #     vinput = ffmpeg.input(vpath)
# #
# #     return vinput,probe

'''
import os

os.environ['http_proxy']='http://10.143.165.150:7001'
os.environ['https_proxy']='http://10.143.165.150:7001'
'''


import requests

import aiohttp

from aiohttp import ClientSession
from aiohttp import TCPConnector

def video_download(path):
    if path.startswith('http'):
        out = requests.get(url=path).content
    else:
        out = open(path, 'rb').read()
    return out


async def img_download(img_url):

    try:
        async with ClientSession(connector=TCPConnector(verify_ssl=False)) as session:
            #async with session.request('GET', img_url,proxy='http://10.143.165.150:7001') as resp:
            async with session.request('GET', img_url) as resp:

                r = await resp.content.read()
    except Exception as e:
        print('error ')
        print(e)
    return r
